<?php
class Article_recycle extends CActiveRecord
{
	public static function model($className = __CLASS__)
	{
		return parent::model($className);
	}
	
	public function tableName()
	{
	    return strtolower(get_class($this));
	}
	
	public function relations()
	{
		return array(
			'relation'=>array(self::HAS_MANY,'Article_category_relation','article_id'),
			'tag_relation'=>array(self::HAS_MANY,'Article_tag_relation','article_id'),
		);
	}
	public static function backup($article)
	{
		$recycle = new self();
		$recycle->id = $article->id;
		$recycle->url_key = $article->url_key;
		$recycle->title = $article->title;
		$recycle->en_title = $article->en_title;
		$recycle->content = $article->content;
		$recycle->en_content = $article->en_content;
		$recycle->create_time = $article->create_time;
		$recycle->update_time = $article->update_time;
		$recycle->is_recommend = $article->is_recommend;
		$recycle->color = $article->color;
		$recycle->visit = $article->visit;
		$recycle->cached = $article->cached;
		$recycle->save();
	}
}